#include <stdio.h>

// 进制转换

int main(int argc, char const *argv[])
{
    char hexChar[16] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
    char intMaxHexChar[8] = {'0','0','0','0','0','0','0','0'};
    int inputNum = 0;
    int target = 10;
    scanf("%d %d", &inputNum, &target);
    
    int remainder = 0;
    int div = inputNum;
    int idx = 0;
    while (div >= target)
    {
        inputNum =  div;
        div = inputNum / target;
        remainder = inputNum % target;
        intMaxHexChar[idx++] = hexChar[remainder];
    }
    if(div != 0) intMaxHexChar[idx] = hexChar[div];
    //printf("0x");
    for (int i = 7; i >= 0; i--)
    {
        /* code */
        printf("%c", intMaxHexChar[i]);
    }
    return 0;
}
